# pip install wordcloud
# pip install stylecloud
from wordcloud import WordCloud
from PIL import Image
import numpy as np
import jieba

with open("notebook.txt", "r") as file:
    s = file.read()
    print(s)
lst = jieba.lcut(s)

mask = np.array(Image.open("300.jpeg"))
print(type(mask))
wordcloud = WordCloud(
    background_color='white',  # 设置背景颜色为白色
    mask=mask,
    font_path='msyh.ttf',
    width=800,
    height=1000,
    stopwords={"这款", "游戏"},
    min_word_length=2,
    max_words=100,  # 设置词汇最大数量为300
    colormap='magma'  # 设置配色集为magma
).generate(" ".join(lst))
wordcloud.to_file('p12.png')
